//
//  AgreementView.m
//  123
//
//  Created by 我的 on 16/7/30.
//  Copyright © 2016年 1243. All rights reserved.
//

#import "AgreementView.h"
#import "agreeModel.h"

@interface AgreementView ()
@property (weak, nonatomic) IBOutlet UIScrollView *scroller;

@property (weak, nonatomic) IBOutlet UIView *backView;

@property (weak, nonatomic) IBOutlet UILabel *negotiateCode;//协议号
@property (weak, nonatomic) IBOutlet UILabel *loanper;//借款人
@property (weak, nonatomic) IBOutlet UILabel *loanIDCard;//借款人身份证号
@property (weak, nonatomic) IBOutlet UILabel *lendPer;//出借人
@property (weak, nonatomic) IBOutlet UILabel *lendIDCard;//出借人身份证号

@property (weak, nonatomic) IBOutlet UILabel *startData;//签订日期
@property (weak, nonatomic) IBOutlet UILabel *porgectCode;//项目编号
@property (weak, nonatomic) IBOutlet UILabel *use;//借款用途
@property (weak, nonatomic) IBOutlet UILabel *content;
@property (weak, nonatomic) IBOutlet UILabel *amont;//
@property (weak, nonatomic) IBOutlet UILabel *rate;//lilv

@property (nonatomic,strong)NSMutableArray *array;

@end

@implementation AgreementView

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"投资协议";
    [self createLeft:[UIImage imageNamed:@"ZHSZicon_03"] leftClick:^{
        [self.navigationController popViewControllerAnimated:NO];
    } right:nil rightClick:nil];
    
    if (self.num != 2) {
        [self getagreement];
    } else {
        _amont.text = @"3、借款本金数额：人民币_______元（借款本金数额100元起且为100的整数倍）。";
        _rate.text = @"6、借款利率：借款期基础年化利率 _______（一年按360天计算）；满标当日起息，借款期限届满后次日结息；借款期限届满后次日本金加利息一次性归还乙方（利息按年化利率算）；若乙方提前赎回，则根据乙方在借款期限内赎回时间不同，收益率计算方式不同，具体见萬元富相应产品赎回规则执行。甲方未能偿付本息的，应按本协议承担逾期还款责任。";
    }
    
}

-(NSMutableArray *)array{
    if (!_array) {
        _array = [NSMutableArray array];
    }
    return _array;
}

-(void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
    if (Screen_Width == 320) {
        _scroller.contentSize = CGSizeMake(0, 4800);
        
    }else{
        _scroller.contentSize = CGSizeMake(0, 4200);
    }
}

-(void)getagreement{
    NSString *loginId = [[NSUserDefaults standardUserDefaults]objectForKey:@"LoginId"];

    NSDictionary *para = @{
                           @"LoginId":loginId,
                           @"brrowListId":self.BorrowListid,
                           @"BrrowId":self.Borrowid
                           };
    [NetWorkManager requestWithType:HttpRequestTypePost withMethodName:@"Api.Getagreement" withParaments:para withSuccessBlock:^(NSDictionary *object) {
        NSDictionary *dic = [object[@"Data"] firstObject];
        agreeModel *model = [agreeModel mj_objectWithKeyValues:dic];
        [self.array addObject:model];
        [self setDataWithModel:model];
        
    } withFailureBlock:^(NSError *error) {
        NSLog(@"%@",error);
    } progress:nil];
}


-(void)setDataWithModel:(agreeModel *)model{
    _negotiateCode.text = [NSString stringWithFormat:@"%@",model.AgreementCode];
    _loanper.text = model.RealName;
    _loanIDCard.text = model.ManCode;
    _lendPer.text = model.TRealName;
    _lendIDCard.text = model.TManCode;
    _startData.text = model.AddDate;
    _porgectCode.text = model.Code;
    _use.text = model.Detail;
    _amont.text = [NSString stringWithFormat:@"3、借款本金数额：人民币  %.2f  元（借款本金数额100元起且为100的整数倍）。",[model.Dedit floatValue]];
    _rate.text = [NSString stringWithFormat:@"6、借款利率：借款期基础年化利率  %.2f%%（一年按360天计算）；满标当日起息，借款期限届满后次日结息；借款期限届满后次日本金加利息一次性归还乙方（利息按年化利率算）；若乙方提前赎回，则根据乙方在借款期限内赎回时间不同，收益率计算方式不同，具体见萬元富相应产品赎回规则执行。甲方未能偿付本息的，应按本协议承担逾期还款责任。",[model.Rate floatValue]];
    
    
    
}

@end
